import {GetterTree, MutationTree} from 'vuex';
import {State} from "@/store/types";
const state: any = {
     currentMenu:""
};

const getters: GetterTree<State, any> = {
     tabName: state => state.TabInfo.name,
     tabUrl: state => state.TabInfo.url
};

const mutations: MutationTree<State> = {
    updateState(state:any, payload:any) {
         const keys=Object.keys(payload);
         keys.forEach((key)=>{
             state[key]=payload[key];
         })
    }
};
const actions: any = {
    addMenuAsync(context, payload) {
        context.commit('updateState', payload);
    }
}

export default {
    namespaced:true,
    actions,
    state,
    mutations,
    getters
};